﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Branch.aspx.cs" MasterPageFile="~/POS.master" Inherits="Admin_Branch" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function clientItemSelected(source, eventArgs) {
            var id_textbox = '<%=hdfCity.ClientID%>';
            document.getElementById(id_textbox).value = eventArgs.get_value();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1">
        
    </asp:ScriptManager>
    <div class="container">
        <h3>Add / Update New Branch</h3>
        <div class="form-horizontal" id="divCustomerWrapper">
             <div class="form-group">
                <label class="control-label col-sm-4" for="Name">Company :</label><asp:Label Text="" ID="Label1" runat="server" />
                <div class="col-sm-6">
                    <asp:DropDownList ID="DDL_Company" OnSelectedIndexChanged="DDL_Company_SelectedIndexChanged" AutoPostBack="true" DataTextField="CompanyName" DataValueField="CompanyId" runat="server">
                    </asp:DropDownList>
                   </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">Branch Name :</label><asp:Label Text="" ID="abc" runat="server" />
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtBranch" class="form-control" placeholder="Branch Name" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter Branch Name" ControlToValidate="txtBranch" runat="server" ForeColor="Red" />
                </div>
            </div>
           
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">City :</label>
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtCity" class="form-control" placeholder="City" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter City" ControlToValidate="txtCity" runat="server" ForeColor="Red" />
                    <cc1:AutoCompleteExtender ID="cityAutoExtender" TargetControlID="txtCity"  ServiceMethod="SearchCities" OnClientItemSelected="clientItemSelected"
                        runat="server" MinimumPrefixLength="2"  CompletionInterval="1000" EnableCaching="true" CompletionSetCount="10">
                    </cc1:AutoCompleteExtender>
                    <asp:HiddenField runat="server" ID="hdfCity" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-4 col-sm-8">
                    <asp:Button runat="server" ID="btnSaveBranch" CssClass="btn btn-success" Text="Save" OnClick="btnSaveBranch_Click" />
                    <asp:Button runat="server" ID="btnClearForm" CssClass="btn btn-danger" Text="Clear Form" CausesValidation="false" OnClick="btnClearForm_Click" />
                </div>
            </div>
        </div>
        <asp:GridView runat="server" ID="GridViewBranches" AutoGenerateColumns="false" CssClass="col-sm-10 grid" AllowPaging="true" PageSize="5" 
            AlternatingRowStyle-BackColor="#ccffff" >
            <Columns>
                <asp:TemplateField HeaderText="Sr.#">
                    <ItemTemplate>
                        <%#Container.DataItemIndex+1 %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Company">
                    <ItemTemplate>
                        <asp:Label ID="lblcompany"  Text='<%#Bind("CompanyName") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Branch">
                    <ItemTemplate>
                        <asp:Label ID="lblBranch"  Text='<%#Bind("BranchName") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="City">
                    <ItemTemplate>
                        <asp:Label ID="lblCity" Text='<%#Bind("City_Name") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Edit">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtnEditBranch" CausesValidation="false" Text="Edit" CommandArgument='<%#Bind("BranchId") %>' OnClick="lbtnEditBranch_Click" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="Delete">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtnDeleteBranch" CausesValidation="false" Text="Delete" CommandArgument='<%#Bind("BranchId") %>' OnClick="lbtnDeleteBranch_Click" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
</asp:Content>